package com.company.indicationshots.util;
//十六进制字符串转成二进制字符串
public class HexToBinaryConverter {

    public static String hexToBinary(String hex) {
        String bin = "";
        String str;
        for (int i = 0; i < hex.length(); i++) {
            char c = hex.charAt(i);
            str = "";
            switch (c) {
                case '0':
                    str = "0000";
                    break;
                case '1':
                    str = "0001";
                    break;
                case '2':
                    str = "0010";
                    break;
                case '3':
                    str = "0011";
                    break;
                case '4':
                    str = "0100";
                    break;
                case '5':
                    str = "0101";
                    break;
                case '6':
                    str = "0110";
                    break;
                case '7':
                    str = "0111";
                    break;
                case '8':
                    str = "1000";
                    break;
                case '9':
                    str = "1001";
                    break;
                case 'A':
                    str = "1010";
                    break;
                case 'a':
                    str = "1010";
                    break;
                case 'B':
                    str = "1011";
                    break;
                case 'b':
                    str = "1011";
                    break;
                case 'C':
                    str = "1100";
                    break;
                case 'c':
                    str = "1100";
                    break;
                case 'D':
                    str = "1101";
                    break;
                case 'd':
                    str = "1101";
                    break;
                case 'E':
                    str = "1110";
                    break;
                case 'e':
                    str = "1110";
                    break;
                case 'F':
                    str = "1111";
                    break;
                case 'f':
                    str = "1111";
                    break;
            }
            bin = bin + str;
        }
        return bin;
    }
}
